function checkPermission(permissonList, callback) {
    var hasresult = api.hasPermission({
        list: permissonList
    });
    var hasPermission = true;
    for (var i = 0; i < hasresult.length; i++) {
        if (!hasresult[i].granted) {
            hasPermission = false;
            break;
        }
    }
    if (!hasPermission) {
        requestPermission(permissonList,callback)
    } else{
        callback(true);
    }

}

function requestPermission(permissonList, callback) {
    api.requestPermission({
        list: permissonList
    }, function (result, err) {
        var isSuccess = true;
        for (var i = 0; i < result.list.length; i++) {
            if (!result.list[i].granted) {
                isSuccess = false;
            }
        }
        callback(isSuccess);
    });

}